<?php
class Login_model extends CI_Model{
	
	function __construct(){
		parent:: __construct();
	}

	
	function insert($nd){
		$query=$this->db->insert('login',$nd);
		if($this->db->affected_rows()>0){
			return $this->db->insert_id();
		}else {
			return 0 ;
		}
		
	}
	
    function check_name($username){
    	
		$sql = "select id from login where username = '$username'";
		//echo $sql;
	    $query= $this->db->query($sql);
	    if($query->num_rows()>0){
	    	return true;
	    }else{
	    	return false;
	    }
	
	}
	
	function check1($name,$pw){
		$sql = "select * from login where username = '$name' and password = '$pw'";
		//echo $sql;
		$query = $this->db->query($sql);
	    if($query->num_rows()>0){
	    	return true;
	    }else{
	    	return false;
	    }
	
	}
}
